<?php
namespace app\back\model;


use app\common\model\WebComm;

class WebModel extends WebComm
{


    ///根据网站链接获取数据
    public function getWebDataByUrl($web_url){
        return collection($this->where('web_url','in',$web_url)->field('assort_id,web_url,web_title,web_description')->select())->toArray();
    }


    ///根据ID修改数据
    public function updateDataByID($web_id,$data){
        return $this->where('web_id',$web_id)->update($data);
    }



    ///获取网站的详细数据包括所属分类
    public function getLeftAssortOneData($data_id){
        return $this->alias('a')->join('dh_assort b','a.assort_id = b.assort_id','LEFT')->where('web_id',$data_id)->field('a.web_id,a.web_title,a.web_url,a.web_description,a.web_sort,a.web_status,a.assort_id,b.assort_title')->find();
    }



    /**
     * 分页获取列表页数据
     * @param array $where_map 筛选参数
     * @param array $query_pram 分页携带参数
     * @return \think\Paginator
     */
    public function getPageIndexDataList($class_id = 0){
        $where_map = array();
        $query_pram = array();
        if($class_id){
            $where_map['b.assort_id'] = $class_id;
            $query_pram['query'] = ['contrller'=>$class_id];
        }
        ///左关联分类表
        $init_obj = $this->alias('a')->join('dh_assort b','a.assort_id = b.assort_id','LEFT');
        ///筛选条件
        $init_obj->where($where_map);
        ///返回结果集
        return $init_obj->order('a.web_status desc,a.web_sort DESC')->field('a.web_id,a.web_title,a.web_url,a.web_description,a.web_sort,a.web_status,a.create_time,a.update_time,a.assort_id,b.assort_title')->paginate(ADMIN_PAGE_LIMIT,false,$query_pram);
    }

}